
import 'dart:async';

import 'package:flutter/services.dart';

class KawaUmeng {
  static const MethodChannel _channel =
      const MethodChannel('kawa_umeng');

  static Future<String> get platformVersion async {
    final String version = await _channel.invokeMethod('getPlatformVersion');
    return version;
  }

  static Future<dynamic> initSdk(String appkey,{String? channel}){
    return _channel.invokeMethod("init",{"appkey":appkey,"channel":channel});
  }

  static Future<dynamic> openDebug(bool isOpen){
    return _channel.invokeMethod("openDebug",{"isDebug":isOpen ? "1" : "0"});
  }
  static Future<dynamic> getOaid(){
    return _channel.invokeMethod("oaid");
  }
  static Future<dynamic> pageStart(String page){
    return _channel.invokeMethod("pageStart",{"page":page});
  }

  static Future<dynamic> pageEnd(String page){
    return _channel.invokeMethod("pageEnd",{"page":page});
  }

  static Future<dynamic> event(String key,[Map<String,String>? map]){
    if (map != null){
      return _channel.invokeMethod("eventCount",{"key":key,...map});
    }
    return _channel.invokeMethod("event",{"key":key});
  }
}
